package org.boun.swe.ARCEONE;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

import android.os.Bundle;
import android.os.StrictMode;
import android.app.Activity;
import android.content.Intent;


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class JsonServerActivity extends Activity {
	

	private static ServerSocket serverSocket;
    private static Socket clientSocket;
    private static InputStreamReader inputStreamReader;
    private static BufferedReader bufferedReader;
    private static String message;
    public static void main(String[] args) {
   	 
        try {
            serverSocket = new ServerSocket(9090);  //Server socket
 
        } catch (IOException e) {
            System.out.println("Could not listen on port: 9090");
        }
 
        System.out.println("Server started. Listening to the port 9090");
 
        while (true) {
            try {
 
                clientSocket = serverSocket.accept();   //accept the client connection
                inputStreamReader = new InputStreamReader(clientSocket.getInputStream());
                bufferedReader = new BufferedReader(inputStreamReader); //get the client message
                message = bufferedReader.readLine();
 
                System.out.println(message);
                inputStreamReader.close();
                clientSocket.close();
 
            } catch (IOException ex) {
                System.out.println("Problem in message reading");
            }
        }
}}